/*
 * LEDS.c
 *
 * Created: 18.11.2012 11:38:17
 *  Author: mariuvi
 */ 

#include <avr/io.h>

#include "definitions.h"


static uint8_t leds_left;

void LEDS_init()
{
	//Set leds as output and pull them high
	BIT_SET(DDRB, PB0);
	BIT_SET(DDRB, PB1);
	BIT_SET(DDRB, PB2);
	
	BIT_SET(PORTB, PB0);
	BIT_SET(PORTB, PB1);
	BIT_SET(PORTB, PB2);
	
	leds_left = 3;	
}

void LEDS_decrement()
{
	//Toggle one led low if there's anyone still on
	if(leds_left>=0)
	{
		leds_left--;
		BIT_CLEAR(PORTB, leds_left);
	}
}